package com.pentalog.bo.impl;

import org.springframework.stereotype.Service;

import com.pentalog.bo.BookBo;
import com.pentalog.domain.Book;
import com.pentalog.domain.BookResponse;
import com.pentalog.exception.BookException;

@Service
public class BookBoImpl implements BookBo{
	public Book getBookByCode(String itemCode){
		Book book = new Book(itemCode);
		book.setBookName("JAVA WEB SERVICE");
		book.setAuthor("Pentalog VN");
		return book;
	}
	public BookResponse getBookResponseByCode(String itemCode) throws BookException{
		BookResponse book = new BookResponse();
		if (itemCode.equals("A1")) {
			throw new BookException("Cannot get book. Code does not exist.");
		}else{
			book = putBook(itemCode, "Java", "p1");
		}
		return book;

	}
	  private BookResponse putBook(String id, String bookName, String author) {
	    BookResponse book = new BookResponse();
	    book.setItemCode(id);
	    book.setBookName(bookName);
	    book.setAuthor(author);
	    return book;
	  }

}
